//package com.pro.framework.monitor;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.stereotype.Component;
//
//@Aspect
//@Component
//public class MethodMonitorAspect {
//
//    private final MeterRegistry meterRegistry;
//
//    public MethodMonitorAspect(MeterRegistry meterRegistry) {
//        this.meterRegistry = meterRegistry;
//    }
//
//    @Around("@annotation(monitorMethod)")
//    public Object monitor(ProceedingJoinPoint joinPoint, MonitorMethod monitorMethod) throws Throwable {
//        String methodName = monitorMethod.value().isEmpty() ? joinPoint.getSignature().getName() : monitorMethod.value();
//        Timer.Sample sample = Timer.start(meterRegistry);
//        boolean success = false;
//        try {
//            Object result = joinPoint.proceed();
//            success = true;
//            return result;
//        } finally {
//            sample.stop(Timer.builder("method.execution")
//                .tag("method", methodName)
//                .tag("class", joinPoint.getTarget().getClass().getSimpleName())
//                .tag("success", String.valueOf(success))
//                .register(meterRegistry));
//        }
//    }
//}